package com.zerox.service.impl;

import com.zerox.mapper.UserMapper;
import com.zerox.pojo.User;
import com.zerox.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
   private UserMapper userMapper ;
    @Override
    public User login(String name, String password) {
        User select = userMapper.select(name);

        if (select==null){
            return null;
        }
        if (password.equals(select.getPassword())){
            return select;
        }
        return null;
    }

    @Override
    public List<User> list(Integer pageNo, Integer pageSize,String realName,Integer roleId) {
        Integer startIndex = (pageNo-1)*pageSize;
        return userMapper.list(startIndex,pageSize,realName,roleId);
    }
    @Override
    public int count(String realName, Integer roleId) {
        return userMapper.count(realName,roleId);
    }

    @Override
    public User show(int id) {
        return userMapper.show(id);
    }

    @Override
    public int delete(int id) {
        return userMapper.delete(id);
    }

    @Override
    public int add(User user) {
        return userMapper.add(user);
    }

    @Override
    public int update(User user) {
        return userMapper.update(user);
    }

}
